package com.haiyou.dc.thread;

/**
 * 静态代理：
 * 1、编写公共接口
 * 2、目标类实现公共接口
 * 2、代理类实现公共接口，构造函数注入
 */
public class StaticProxy {

    public static void main(String[] args) {
        new Wedding(new You()).happy();
    }
}

/**
 * 公共接口
 */
interface Marry {
    void happy();
}

class You implements Marry {

    @Override
    public void happy() {
        System.out.println("很高兴......");
    }
}

class Wedding implements Marry {

    private Marry marry;

    public Wedding(Marry marry) {
        this.marry = marry;
    }

    @Override
    public void happy() {
        begin();
        this.marry.happy();
        end();
    }

    private void end() {
        System.out.println("wedding is end ....");
    }

    private void begin() {
        System.out.println("wedding is begin....");
    }
}
